package ca.camosun.chatbox.network;

import java.util.ArrayList;

import ca.camosun.chatbox.profile.Profile;
import ca.camosun.chatbox.message.Message;

public class FakeChatController {
	
	private Profile myProfile;
	private FakeRoomProximityController chatRoom;
	private ArrayList<String> fakeMessages;
	static int fakeMessageCounter;
	
	public FakeChatController() {
		myProfile = new Profile("Me");
		
		chatRoom.findAllProfiles();
		
		fakeMessageCounter = 0;
		
		composeFakeMessages();
	}
	
	public void composeFakeMessages() {
		String content0 = "message one.";
		String content1 = "message two.";
		String content2 = "message three.";
		String content3 = "message four.";
		String content4 = "message five.";
		String content5 = "message six.";
		String content6 = "message seven.";
		String content7 = "message eight.";
		String content8 = "message nine.";
		String content9 = "message ten.";
		
		fakeMessages.add(content0);
		fakeMessages.add(content1);
		fakeMessages.add(content2);
		fakeMessages.add(content3);
		fakeMessages.add(content4);
		fakeMessages.add(content5);
		fakeMessages.add(content6);
		fakeMessages.add(content7);
		fakeMessages.add(content8);
		fakeMessages.add(content9);
	}
	
	public void sendMessage() {
		
		String messageContent = fakeMessages.get(fakeMessageCounter);
		
		Message myMessage = new Message(myProfile, messageContent);
		
		System.out.print("Send - " + myProfile.getName() + ": " + myMessage.getContent());
		
		fakeMessageCounter++;
		
		if(fakeMessageCounter >= fakeMessages.size()) {
			fakeMessageCounter = 0;
		}
	}
	
	public void receiveMessage(Message aMessage) {
		
		Profile messageProfile = aMessage.getSender();
		String messageContent = aMessage.getContent();
		
		System.out.print("Received - " + messageProfile.getName() + ": " + messageContent);
		
		fakeMessageCounter++;
		
		if(fakeMessageCounter >= fakeMessages.size()) {
			fakeMessageCounter = 0;
		}
	}
	
}
